import Vue from 'vue'
import vuex from 'vuex'
import axios from 'axios'

Vue.use(vuex)

const state={
    courseId:'',
    courseImg:''
}

const mutations={
    setCourseId(state,n){
        state.courseId=n;
    },
    getCourseimg(state){
        axios.get("https://www.easy-mock.com/mock/5b0266d995118136368f1a78/banner", {
          courseid: state.courseId
        })
        .then(res => {
            console.log("banner请求"+res.data.image,state.courseId);
            state.courseImg = res.data.image;
        })
        .catch(error => {
          alert(error);
        });
    }
}

export default new vuex.Store({
    state,
    mutations
})